<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>编辑数据上报</title>
		<link rel="stylesheet" type="text/css" href="/webapp/css/easyui.css">
	    <link rel="stylesheet" type="text/css" href="/webapp/css/icon.css">
        <link rel="stylesheet" type="text/css" href="/webapp/css/color.css">
        <link rel="stylesheet" type="text/css" href="/webapp/css/public.css">
	    <script type="text/javascript" src="/webapp/js/lib/jquery.min.js"></script>
	    <script type="text/javascript" src="/webapp/js/lib/jquery.easyui.min.js"></script>
	    <script type="text/javascript" src="/webapp/js/lib/ajaxfileupload.js"></script>
	    <script type="text/javascript" src="/webapp/js/common/config.js"></script>
	</head>
	<body>
		<div class="easyui-container-fluid">
			<div class="easyui-panel" style="border:none;">
				<div class="nav" id="nav"></div>
				<div class="easyui-panel" style="border:none;">
					<form id="ff">
						<div style="margin-bottom:20px;">
							<label class="item-label">渠道：</label>
							<input type="text" class="easyui-textbox" name="channelName" style="width:170px;" readonly="readonly"/>
						</div>
						<div style="margin-bottom:20px;">
							<label class="item-label">报告类型：</label>
							<input type="text" class="easyui-textbox" name="reportTypeName" style="width:170px;" readonly="readonly"/>
						</div>
                        <div style="margin-bottom:20px;">
                            <label class="item-label">报告编码：</label>
                            <input type="text"  class="easyui-textbox" name="code" style="width:170px;" data-options="panelHeight:'auto'" readonly="readonly"/>
                        </div>
						<div style="margin-bottom:20px;">
							<label class="item-label">报告年份：</label>
							<input type="text" class="easyui-combobox" name="reportYear" style="width:170px;" data-options="panelHeight:'auto'" required="required"/>
						</div>
						<div style="margin-bottom:20px;">
							<label class="item-label">报告月份：</label>
							<input type="text" id="reportMonth" class="easyui-textbox" name="reportMonth" style="width:170px;" data-options="panelHeight:'auto'" readonly="readonly"/>
						</div>
						<div style="margin-bottom:20px;">
							<label class="item-label">报告周：</label>
							<input type="text" id="reportWeek" class="easyui-textbox" name="reportWeek" style="width:170px;" data-options="panelHeight:'auto'" readonly="readonly"/>
						</div>
						<div style="margin-bottom:20px;">
							<label class="item-label">开始时间：</label>
							<input type="text" id="reportBeginDate" class="easyui-datebox" data-options="formatter:dateFormatter,parser:dateParser" name="reportBeginDate" required="required"/>
						</div>
						<div style="margin-bottom:20px;">
							<label class="item-label">结束时间：</label>
							<input type="text" id="reportEndDate" class="easyui-datebox" data-options="formatter:dateFormatter,parser:dateParser" name="reportEndDate" required="required"/>
						</div>
						<div style="margin-bottom:20px;margin-left: 100px;">
							<a href="javascript:void(0);" class="easyui-linkbutton c8" onclick="submitForm()" style="width: 80px;">修改</a>
							<a href="javascript:void(0);" class="easyui-linkbutton" onclick="cancel()" style="width: 80px;">取消</a>
						</div>
					</form>
				</div>
			</div>
		</div>
		<script type="text/javascript">
			var reportTypes={
				"WEEK":"周报",
				"MONTH":"月报"
			}
            $(function(){
                setNav();
                var id = getQueryParameter("id");
                $.ajax({
                	type:"get",
                	url:config.url+"/dataReport/"+id,
                	async:true,
                	xhrFields:{withCredentials:true},
                	success:function(data){
                		if(data){
                			data.reportTypeName=reportTypes[data.reportType];
		                    $("#ff").form("load",changeProperty2String(data));
		                }   
                	}
                });
            });
            function submitForm(){
            	$("#ff").form("submit",{
            		onSubmit:function(){
            			var valid = $(this).form("enableValidation").form("validate");
            			if(valid){
            				var data = getFormData(document.getElementById("ff"));
            				$.ajax({
            					 url:config.url+"/dataReport/"+getQueryParameter("id"),
		                         type:"POST",
		                         data:JSON.stringify(data),
		                         dataType:'json',
		                         contentType:'application/json;charset=UTF-8',
		                         beforeSend:function(){
		                            window.parent.window.load();
		                         },
		                         complete:function(){
		                            window.parent.window.disLoad();
		                         },
		                         xhrFields:{withCredentials:true},
		                          success:function(data){
		                              $.messager.alert("提示","操作成功","info",function(){
                                          window.parent.closeCurrentTab(true);
		                              });
		                          },
		                          error:function(XMLHttpRequest,textStatus,thrown){
		                              $.messager.alert("提示","操作失败","error");
		                          }
            				});
            				return false;
            			}
            			return false;
            		}
            	})
            }
            function dateFormatter(date) {
                console.log("date:",date);
                var y = date.getFullYear();
                var m = date.getMonth()+1;
                if(m<10){
                    m="0"+m;
                }
                var d = date.getDate();
                if(d<10){
                    d="0"+d;
				}
                return y+'-'+m+'-'+d;
            }
            function dateParser(date) {
				
            }
            function cancel() {
                window.parent.closeCurrentTab();
            }
		</script>
	</body>
</html>